package easy;

import util.PrintUtils;

public class Solution_LCP_02 {

    public int[] fraction(int[] cont) {
        int n = cont[cont.length - 1], m = 1;
        for (int i = cont.length - 2; i >= 0; i--) {
            int val = n;
            n = cont[i] * n + m;
            m = val;
        }
        int a = Math.max(n, m), b = Math.min(n, m);
        while (a % b != 0) {
            int temp = b;
            b = a % b;
            a = temp;
        }
        return new int[]{n / b, m / b};
    }

    public static void main(String[] args) {
        Solution_LCP_02 model = new Solution_LCP_02();
        PrintUtils.arrayInt(model.fraction(new int[]{3, 2, 0, 2}));
        PrintUtils.arrayInt(model.fraction(new int[]{0, 0, 3}));
    }
}
